//
//  BPUISearchNavigationView.m
//  AFNetworking
//
//  Created by 404 on 2020/7/31.
//

#import "BPUISearchNavigationView.h"

@implementation BPUISearchNavigationView

- (void)didInitialize {
    [super didInitialize];
    self.backgroundColor = [UIColor whiteColor];
    self.titleLabel.hidden = YES;
    
    _searchBackgroundView = [[UIView alloc] init];
    _searchBackgroundView.layer.cornerRadius = 16;
    _searchBackgroundView.layer.masksToBounds = YES;
    _searchBackgroundView.backgroundColor = UIColorMake(241, 241, 241);
    [self addSubview:_searchBackgroundView];
    
    _searchIconView = [[UIImageView alloc] initWithImage:
                       UIImageMake(@"nav_search.png")];
    [self.searchBackgroundView addSubview:_searchIconView];
    
    _searchTextField = [[UITextField alloc] init];
    _searchTextField.font = UIFontMake(16);
    _searchTextField.placeholder = @"搜索服务";
    [self.searchBackgroundView addSubview:_searchTextField];
    
    _coverButton = [[UIButton alloc] init];
    [self.searchBackgroundView addSubview:_coverButton];
}

- (void)layoutSubviews {
    
    self.searchBackgroundView.frame = CGRectMake(15, STATUS_HEIGHT + 6, CGRectGetWidth(self.frame) - 15 * 2, 32);
    self.searchIconView.frame = CGRectMake(8, 8, 15, 15);
    self.searchTextField.frame = CGRectMake(CGRectGetMaxX(self.searchIconView.frame) + 8, 0, self.searchBackgroundView.width - (CGRectGetMaxX(self.searchIconView.frame) + 8) * 2, CGRectGetHeight(self.searchBackgroundView.frame));
    self.coverButton.frame = self.searchBackgroundView.bounds;
}
@end
